﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Prices
{
    public class Product
    {
        private string name;
        private int price;
        public event priceIncreasedHendler priceIncreased;

        public Product(string name, int price)
        {
            this.name = name;
            this.price = price;
        }

        public string Name
        {
            get
            {
                return name;
            }
            set
            {
                name = value;
            }
        }

        public int Price
        {
            get
            {
                return price;
            }
            set
            {
                if (value > price) 
                {
                    OnPriceIncrease(value);
                }
                price = value;
            }
        }

        protected void OnPriceIncrease(int newPrice) 
        {
            if (this.priceIncreased != null)
            {
                PriceIncreasedEventArgs args = new PriceIncreasedEventArgs(this.Price, newPrice);
                priceIncreased(this, args);
            }

        }
       
        public delegate void priceIncreasedHendler(object sender, PriceIncreasedEventArgs args);
    }
}
